package org.neu.onlineparadise.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.neu.onlineparadise.entity.User;

@Mapper
public interface UserMapper {

    @Select("select  * from user where username=#{name}")
    User findByName(String username);


    @Insert("Insert into user (username, password,create_time,update_time) values(#{username},#{password},now(),now())")
    void register(String username, String password);


    @Update("Update user set password=#{password},update_time=now() where id=#{id}")
    void updatePwd(String password, Integer id);

    @Update("Update user set nickname=#{nickname},email=#{email},update_time=now()")
    void updateUserInfo(User user);

    @Update("Update user set user_pic=#{avatarURL},update_time=now() where id=#{id}")
    void updateAvatar(String avatarURL, Integer id);
}
